package rlpw.swing;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;

public class ColorIcon extends ImageIcon {

    public ColorIcon(Color c) {
        this(c, 16, 16);
    }

    public ColorIcon(Color c, int width, int height) {

        BufferedImage bdest = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = bdest.createGraphics();
        g.setColor(c);
        g.fill3DRect(2, 2, width - 4, height - 4, true);
        g.dispose();

        this.setImage(new ImageIcon(bdest).getImage());

    }
}
